library(ggplot2)

### load work place ####
setwd("C:/Users/deram/OneDrive - IAEA/Desktop/Dera/Dera 2/genetic population/microsatellites_paper/Manuscript/last")

###Evaluation of the presence of SAD

## loading of the data for the checking of SAD
sad <- read.csv("SAD.csv")
sad
summary(sad)
str(sad)

#checking the presence of SAD in Pgp24 loci
pgp24 <- subset(sad,Loci=="Pgp24")
pgp24
with(pgp24, cor.test(Allele, Capf, alternative="less", method="spearman"))
#checking the presence of SAD in Pgp24 loci
B3 <- subset(sad,Loci=="B3")
B3
with(B3, cor.test(Allele, Capf, alternative="less", method="spearman"))

#checking the presence of SAD in Pgp24 loci
C102 <- subset(sad,Loci=="C102")
C102
with(C102, cor.test(Allele, Capf, alternative="less", method="spearman"))

#checking the presence of SAD in Pgp24 loci
pgp15 <- subset(sad,Loci=="Pgp15")
pgp15
with(pgp15, cor.test(Allele, Capf, alternative="less", method="spearman"))

#checking the presence of SAD in Pgp24 loci
pgp16 <- subset(sad,Loci=="Pgp16")
pgp16
with(pgp16, cor.test(Allele, Capf, alternative="less", method="spearman"))

#checking the presence of SAD in Pgp24 loci
pgp27 <- subset(sad,Loci=="Pgp27")
pgp27
with(pgp27, cor.test(Allele, Capf, alternative="less", method="spearman"))
mod<-lm(formula = Smallf ~ Allele, data = pgp27, weights = Weight)
summary(mod)

#checking the presence of SAD in Pgp24 loci
X55.3 <- subset(sad,Loci=="X55.3")
X55.3
with(X55.3, cor.test(Allele, Capf, alternative="less", method="spearman"))


#checking the presence of SAD in Pgp24 loci
Xpgp13 <- subset(sad,Loci=="XPgp13")
Xpgp13
with(Xpgp13, cor.test(Allele, Capf, alternative="less", method="spearman"))

#checking the presence of SAD in Pgp24 loci
XB104 <- subset(sad,Loci=="XB104")
XB104
with(XB104, cor.test(Allele, Capf, alternative="less", method="spearman"))
mod<-lm(formula = Smallf ~ Allele, data = XB104, weights = Weight)
summary(mod)

#checking the presence of SAD in Pgp24 loci
XB110 <- subset(sad,Loci=="XB110")
XB110
with(XB110, cor.test(Allele, Capf, alternative="less", method="spearman"))
mod<-lm(formula = Smallf ~ Allele, data = XB110, weights = Weight)
summary(mod)

##Evaluation of the correlation between FIS and FST and FIS and number of Blank

data_reg <- read.csv("data_reg.csv")
data_reg
summary(data_reg)
str(data_reg)

#Correlation between FIS and FST
with(data_reg, cor.test(FIS, FST, alternative="greater", method="spearman"))

#Correlation between FIS and Number of blank
with(data_reg, cor.test(FIS, Nblank, alternative="greater", method="spearman"))
